package com.hzh.MLlib

import org.apache.spark.ml.classification.LogisticRegressionModel
import org.apache.spark.sql.{DataFrame, SparkSession}

object DemoUseModel {
  def main(args: Array[String]): Unit = {
    /**
     * 创建环境
     *
     */

    val spark: SparkSession = SparkSession
      .builder()
      .config("spark.sql.shuffle.partitions", 1)
      .master("local[6]")
      .appName("Demo2Photos")
      .getOrCreate()

    import org.apache.spark.sql.functions._
    import spark.implicits._

    val testDF: DataFrame = spark
      .read
      .format("libsvm")
      .option("numFeatures", 784) //指定特征的长度
      .load("data/image_data_test2")




    val model: LogisticRegressionModel = LogisticRegressionModel.load("data/image_model")

    val resultDF: DataFrame = model.transform(testDF)

    resultDF.show(100)




  }
}
